Skip to main content

All Questions

2votes
0answers
101views

How to Use Webpack with WordPress Script Modules and Enqueue a Custom Class

I am working on a WordPress project using version 6.5, which introduced support for JavaScript modules. I have a parent theme that exports a JavaScript class, and I want to import this class in a ...
Nani samireddy's user avatar
3votes
1answer
878views

Loading newest dependency javascript module file in functions.php

Continuing from this question: I have scripts enqueued in functions.php file so scripts load only on certain pages (I cut most of them in code below): add_action( 'template_redirect', 'plugin_is_page' ...
FilipD's user avatar
4votes
1answer
337views

Auto updating JavaScript dependancy in functions.php

I'm enqueuing scripts with dependency in functions.php file like: wp_enqueue_script('ads', get_template_directory_uri() . '/js/ads.js', array( ), '1.6', true); wp_enqueue_script('banners', ...
FilipD's user avatar
0votes
0answers
151views

wp_enqueue_script JS code runs too late (after user begins interacting)

The issue is that we need to replace some HTML based on the user's user agent string but by the time the JS code is loaded and runs, the user is already interacting with the page. Is there some way to ...
Slbox's user avatar
1vote
0answers
475views

Wordpress load same script two times

I write a basic plugin with custom css/js. I use wp_enqueue_script for my custom script and use hook 'init' to register script in front-end page. But wordpress load this javascript file two times with ...
tecnico57's user avatar
2votes
1answer
2kviews

wp_add_inline_script not adding when script_loader_tag filtered

I'm trying to add the new GA4 code to an existing site, and there seems to be some conflict / ordering issue between script_loader_tag filters and wp_add_inline_script. My functions.php looks thusly: ....
philolegein's user avatar
1vote
1answer
457views

Retrieve URL of Script/Style and Dependencies

Given script X Y and Z how would I get the list in PHP of X Y Z and their dependencies? I need to load several scripts that have dependencies. Normally I would do this via wp_enqueue_script but in ...
Tom J Nowell's user avatar
  • 61.2k
0votes
0answers
63views

Why can I not deregister my style and script on custom post type?

I have a website where I have a custom post type with some single pages attached to it. Problem: I can't deregister the scripts and styles on my custom post type single pages. This is my code: ...
Siyah's user avatar
0votes
1answer
1kviews

Enqueue Script in custom plugin before other

I've got a conflict with another plugin which is blocking the JS in my custom plugin with the hook: add_action('wp_enqueue_scripts', '<FOREIGN-PLUGIN>'); Is there a way to enqueue my JS before ...
murcoder's user avatar
0votes
1answer
459views

Unable to defer loading of jquery

I have two render blocking JS from wordpress core. jquery.js and jquery-migrate.min.js. Following this answer on WPSE I was able to add `defer="defer"' to the script tag that calls for jquery-migrate ...
OctaviaLo's user avatar
1vote
1answer
766views

My scripts-bundle.js file is getting sent to the browser as a stylesheet css file. Help!

I'm new to WordPress custom theme development. I am using a child theme for OceanWP. I have a webpack setup to hot-reload my files but my js scripts are not getting sent to my WordPress site instead ...
wen ten's user avatar
0votes
1answer
285views

Changing URL of scripts, scripts outside theme folder?

Is it possible to have css and js scripts outside of template directory? If it is possible, how can I achieve it? Basically, instead of having: http://example.com/wp-content/themes/mytheme/assets/...
dodo254's user avatar
0votes
0answers
38views

Scripts don't enqueue after removing plugin

Using the Ultimate Member plugin. My custom scripts are loading in my child-theme as follows: function some_theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() ...
MAR's user avatar
  • 109
2votes
1answer
2kviews

Select2 in WordPress

I have seen some best practices in WordPress about enqueueing scripts in WordPress. The scripts that are already in WordPress core should not be added again, but call that from WordPress core. I want ...
Shadow's user avatar
1vote
0answers
135views

Styles and scripts inside template part

Is there anything wrong with including style and script tags inside a template part? The template part which I'm using like something more similar to a vue/react component is working correctly but ...
feedmeimhungry's user avatar

153050per page
close